//
//  MyOrderCell.m
//  LoveTrail
//
//  Created by giantumbrella on 15/6/22.
//  Copyright (c) 2015年 赵娟. All rights reserved.
//

#import "MyOrderCell.h"
#import "CommonMacro.h"
#import "MyOrderModel.h"
#import "UIImageView+WebCache.h"

@interface MyOrderCell ()

@property (nonatomic,strong) UIView *cellBgView;
@property (nonatomic,strong) UILabel *orderLabel;
@property (nonatomic,strong) UIImageView *pictureImageView;
@property (nonatomic,strong) UILabel *titleLabel;
@property (nonatomic,strong) UILabel *priceLabel;
@property (nonatomic,strong) UILabel *colorLabel;
@property (nonatomic,strong) UILabel *numLabel;
@property (nonatomic,strong) UIButton *chekButton;
@end

@implementation MyOrderCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
       
        [self createSubviews];
    }
    return self;
}

- (void)layoutSubviews
{
    [self valueWithSubviews];
}

#pragma mark 创建可见视图
- (void)createSubviews
{
    //1.添加大背景
//    self.cellBgView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, self.bounds.size.width-20, self.bounds.size.height) style:UITableViewStylePlain];
    self.cellBgView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, 100) style:UITableViewStylePlain];
//    self.cellBgView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, SCREEN_HEIGHT*0.2) style:UITableViewStylePlain];

      [self addSubview:self.cellBgView];
    self.cellBgView.backgroundColor = [UIColor cyanColor];
    self.cellBgView.layer.cornerRadius = 5;
    self.cellBgView.clipsToBounds = YES;
    
   NSLog(@"tableviewcell :%@",NSStringFromCGRect(self.cellBgView.frame));
    NSLog(@"self.frame :%@",NSStringFromCGRect(self.frame));

    
    //2.订单号
//    self.orderLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.cellBgView.frame.origin.x, self.cellBgView.frame.origin.y, self.cellBgView.frame.size.width, self.cellBgView.frame.size.height*0.15)];
//    self.orderLabel.textColor = UIColorWithRGBA(253, 241, 240, 1);
//    self.orderLabel.backgroundColor = UIColorWithRGBA(211, 78, 31, 1);
//    [self addSubview:self.orderLabel];
    
    //3.添加商品图片
//    self.pictureImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.orderLabel.frame.origin.x+10, self.orderLabel.frame.origin.y+self.orderLabel.frame.size.height+14, self.cellBgView.frame.size.width*0.35, self.cellBgView.frame.size.height*0.7)];
//    self.pictureImageView.backgroundColor = [UIColor greenColor];
//    [self addSubview:self.pictureImageView];
    
//    //4.添加详细内容叙述
//    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.pictureImageView.frame.origin.x+self.pictureImageView.frame.size.width+3,self.orderLabel.frame.origin.y+self.orderLabel.frame.size.height+3 ,self.cellBgView.frame.size.width*0.56, self.cellBgView.frame.size.height*0.1)];
//    //    titleLabel.backgroundColor = [UIColor redColor];
//    self.titleLabel.textColor = UIColorWithRGBA( 131, 127, 127, 1);
//    self.titleLabel.numberOfLines = 0;
//    [self.titleLabel sizeToFit];
//    self.titleLabel.font = [UIFont systemFontOfSize:15];
//    [self addSubview:self.titleLabel];
//    
//    //5.添加价钱
//    self.priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.titleLabel.frame.origin.x, self.titleLabel.frame.size.height+self.titleLabel.frame.origin.y, self.titleLabel.frame.size.width*0.5, self.cellBgView.frame.size.height*0.2)];
//     self.priceLabel.text = self.myOrderModel.price;
//    //    priceLabel.backgroundColor = [UIColor greenColor];
//    [self addSubview:self.priceLabel];
//    
//    //6.添加颜色 数量
//    self.colorLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.titleLabel.frame.origin.x-10, self.priceLabel.frame.origin.y+self.priceLabel.frame.size.height+12,self.priceLabel.frame.size.width*0.88, self.priceLabel.frame.size.height*0.3)];
////        self.colorLabel.backgroundColor = [UIColor blueColor];
//    self.colorLabel.textColor = UIColorWithRGBA(176, 174, 174, 1);
//    self.colorLabel.numberOfLines = 0;
//    [self.colorLabel sizeToFit];
//    self.colorLabel.font = [UIFont systemFontOfSize:12];
//    [self.cellBgView addSubview:self.colorLabel];
//    
//    self.numLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.colorLabel.frame.size.width+3+self.colorLabel.frame.origin.x, self.colorLabel.frame.origin.y+self.colorLabel.frame.size.height*0.4, self.priceLabel.frame.size.width*0.66, self.priceLabel.frame.size.height*0.2)];
//    self.numLabel.textColor = UIColorWithRGBA(158, 156, 156, 1);
//    self.numLabel.font = [UIFont systemFontOfSize:12];
//    //    numLabel.backgroundColor = [UIColor greenColor];
//    [self.cellBgView addSubview:self.numLabel];
//    
//    //7.添加立即付款 或 确认收货按钮
//    self.chekButton = [[UIButton alloc] initWithFrame:CGRectMake(self.cellBgView.frame.size.width-self.priceLabel.frame.size.width*0.92, self.priceLabel.frame.origin.y-10, self.priceLabel.frame.size.width*0.8, self.priceLabel.frame.size.height)];
//    self.chekButton.backgroundColor = UIColorWithRGBA(247, 122, 77, 1);
//    [self.chekButton setTitle:@"立即付款" forState:UIControlStateNormal];
//    self.chekButton.layer.cornerRadius = 5;
//    self.chekButton.clipsToBounds = YES;
//    [self.chekButton.titleLabel setFont:[UIFont systemFontOfSize:15]];
//    [self.cellBgView addSubview:self.chekButton];

}

#pragma mark 赋值过程
- (void)valueWithSubviews
{
//    self.orderLabel.text = [NSString stringWithFormat:@"订单号：%@",self.myOrderModel.orderNumber];
//    [self.pictureImageView setImageWithURL:[NSURL URLWithString:self.myOrderModel.img]];
//    self.titleLabel.text = self.myOrderModel.descriptionText;
//    self.priceLabel.text = self.myOrderModel.price;
//    self.numLabel.text = self.myOrderModel.amount;
//    self.colorLabel.text = self.myOrderModel.other;
}
@end
